#include <iostream>
#include <vector>

using namespace std;

// 1052. 爱生气的书店老板
// https://leetcode.cn/problems/grumpy-bookstore-owner/description/

class Solution {
public:
    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {
        int left = 0;
        int ans = 0;
        int maxAngryHuman = 0;
        int curAngryHuman = 0;
        for (int i = 0; i < customers.size(); i++)
        {
            if(grumpy[i] == 0){
                ans += customers[i];
            }else{
                curAngryHuman += customers[i];
            }

            if(i - left + 1 < minutes){
                continue;
            }

            maxAngryHuman = max(maxAngryHuman, curAngryHuman);

            curAngryHuman -= (grumpy[left] == 0 ? 0 : customers[left]);
            left++;
        }
        return ans + maxAngryHuman;
    }
};

int main()
{
    return 0;
}